package com.example.demo.properties;

import com.example.demo.util.YamlPropertyLoaderFactory;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author: YanMing.Wang
 * @date: 2024-02-28
 * @desp: 读取bootstrap配置文件信息
 */
@Component
@PropertySource(value = "classpath:bootstrap.yml", encoding = "UTF-8", factory = YamlPropertyLoaderFactory.class)
// 其他读取yml文件的地方,已经引入factory,此处也需要引入自定义factory,否则启动时报读取不到信息错误
@Data
public class BootStrapProps {

    @Value(value = "${server.port}")
    // 优先加载application.properties文件>yml后面不再读取
    private String port;

    @Value(value = "${spring.application.name}")
    private String name;


}
